import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:myflutterproject/basematerialwidgetsdemo.dart';

class CupertinosliderDemo extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => CupertinosliderState();
}

class CupertinosliderState extends State<CupertinosliderDemo> {
  double _process1 = 0;
  double _process2 = 10;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Cupertinoslider'),
        centerTitle: true,
      ),
      body: Column(
        children: [
          TextWidget('普通：'),
          _myCupertinoSlider1(),
          Padding(padding: EdgeInsets.all(20)),
          TextWidget('分为几块：'),
          _myCupertinoSlider2()
        ],
      ),
    );
  }

  _myCupertinoSlider1() {
    return CupertinoSlider(
      value: _process1,
      onChanged: (progress) {
        setState(() {
          _process1 = progress;
        });
      },
      onChangeStart: (progress) {
        print('onChangeStart progress = $progress');
      },
      onChangeEnd: (progress) {
        print('onChangeEnd  progress = $progress');
      },
      min: 0,
      max: 100,
      activeColor: Colors.blue,
    );
  }

  _myCupertinoSlider2() {
    return CupertinoSlider(
      value: _process2,
      onChanged: (progress) {
        setState(() {
          _process2 = progress;
        });
      },
      onChangeStart: (progress) {
        print('onChangeStart progress = $progress');
      },
      onChangeEnd: (progress) {
        print('onChangeEnd  progress = $progress');
      },
      min: 0,
      //分为几块，比如设置为10，Slider只能滑动到10个位置
      divisions: 10,
      max: 100,
      activeColor: Colors.blue,
    );
  }
}
